<?php
  class Plugins_Bookupload extends model {
  
  
  
  function getformadd($productid="")
  {
  
$str='<div class="wrpPlg clBg5 clBd2 bdFull">
                    <div class="wrpOutAtcPlg">
                        <div class="wrpAtcPlg">
                            <span class="icoZavPlg"></span>
                            <div class="spnAtcPlg clTxtW">
                                <span class="txtAtcPlg fs03">ZAVE File</span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpTl">
                        <div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">
                            <span class="ico icoCloseTl"></span>
                        </div>
                    </div>
                    <form class="frmZavPlg">
                        <div class="wrpZavArea clearfix">
                            <div class="zavFile zav1 areafile">
                                <div class="wrprIcoZavFile">
                                    <div class="wrpIcoZavFile">
                                        <span class="icoZavFile"></span>
                                    </div>
                                    <div class="txtZavFlie">
                                        <span class="clTxtW fs05">ZAVE</span>
                                        <span class="clTxtW fs03">0%</span>
                                    </div>
                                </div>
                                <div class="wrpNameZavFile mgBtm10">
                                    <div class="clTxt2 cutTxt nameZavFile fs03"></div>
                                    <div class="clTxt2 cutTxt sizeZavFile fs03"></div>
                                </div>
                                <div class="wrpBtnZavFile clearfix">
                                    <div class="wrpInBtnZavFile clBgBt2">
                                        <div class="wrpUlFile">
                                        
                                        </div>
                                        <div class="btnZavFile">
                                            <span class="icoAddZav"></span>
                                        </div>
                                    </div>
                                    <div class="wrpInBtnZavFile clBgBt2 deletebtn">
                                        <div class="btnZavFile">
                                            <span class="icoDelZav"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="zavFile zav2">
                                <div class="wrprIcoZavFile">
                                    <div class="wrpIcoZavFile">
                                        <span class="icoZavFile"></span>
                                    </div>
                                    <div class="txtZavFlie">
                                        <span class="clTxtW fs05">ZAVEC</span>
                                        <span class="clTxtW fs03">0%</span>
                                    </div>
                                </div>
                                 <div class="wrpNameZavFile mgBtm10">
                                    <div class="clTxt2 cutTxt nameZavFile fs03"></div>
                                    <div class="clTxt2 cutTxt sizeZavFile fs03"></div>
                                </div>
                                <div class="wrpBtnZavFile clearfix">
                                    <div class="wrpInBtnZavFile clBgBt2">
                                        <div class="wrpUlFile">
                                        
                                        </div>
                                        <div class="btnZavFile">
                                            <span class="icoAddZav"></span>
                                        </div>
                                    </div>
                                    <div class="wrpInBtnZavFile clBgBt2 deletebtn">
                                        <div class="btnZavFile">
                                            <span class="icoDelZav"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="zavFile zav3">
                                <div class="wrprIcoZavFile">
                                    <div class="wrpIcoZavFile">
                                        <span class="icoZavFile"></span>
                                    </div>
                                    <div class="txtZavFlie">
                                        <span class="clTxtW fs05">ZAVEM</span>
                                        <span class="clTxtW fs03">0%</span>
                                    </div>
                                </div>
                                
                                
                                <div class="wrpNameZavFile mgBtm10">
                                    <div class="clTxt2 cutTxt nameZavFile fs03"></div>
                                    <div class="clTxt2 cutTxt sizeZavFile fs03"></div>
                                </div>
                                
                                <div class="wrpBtnZavFile clearfix">
                                    <div class="wrpInBtnZavFile clBgBt2">
                                     <div class="wrpUlFile">
                                        
                                        </div>
                                        <div class="btnZavFile">
                                            <span class="icoAddZav"></span>
                                        </div>
                                    </div>
                                    <div class="wrpInBtnZavFile clBgBt2 deletebtn">
                                        <div class="btnZavFile">
                                            <span class="icoDelZav"></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            

                        </div>
                    </form>
                </div>';
  
  
  
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $str));
 // $arraydata['js'][]=pluginjsinfo.'/upload.js';


  
  
      
  
  
  
  return $arraydata;
  
  
  
  
  
  
  
  }
  
  function getformlanding($arraydata)
  {
$code="";

if($arraydata['filezave']['filename']&&$arraydata['filezavec']['filename']&&$arraydata['filezavem']['filename'])
{
//$code = '<div class="ldIt wrpDlLd clBg4">';
//$code .= '<h2 class="clTxt2 fs04">Download Menu</h2>';
//$code .= '<div class="wrpInDlLd">';
//$code.= '<div class="btnIco dlLd">';
//$code.= '<abbr title="Download">';
//$code.= '<span class="ico2 icoDlLd"></span>';
//$code.= '</abbr>';
//$code.= '</div>';
//$code.= '<a href="'.$arraydata['file']['newpath'].'" target="_blank">';
//$code.= '<div class="desFileDlLd">';
//$code.= '<span class="fileName">'.$arraydata['file']['filename'].'</span><br>';
//$code.= '<span class="fileSize">'.$arraydata['file']['size'].' kb</span>';
//$code.= '</div>';
//$code.= '</a>';
//$code.= '</div>';
//$code.= '<div class="desDlLd">';
//$code.= '<p>'.$arraydata['detail'].'</p>';
//$code.= '</div>';
//$code.= '</div>';


$code  = '<div class="ldIt wrpDlZaveLd clBg4">'."\n";
$code .= '<h2 class="clTxt2 fs04 boldGen">Download ZAVE File</h2>'."\n";
$code .= '<div class="wrpOutDlZaveLd">'."\n";
$code .= '<div class="wrpInDlZaveLd clearfix">'."\n";
$code .= '<div class="wrpOutDlZave">'."\n";
$code .= '<div class="wrpDlZave">'."\n";
$code .= '<a href="'.$arraydata['filezave']['newpath'].'">'."\n";
$code .= '<div class="btnIco dlZaveLd">'."\n";
$code .= '<span class="ico2 icoDZavelLd"></span>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="btnDlZaveFile" onclick="">'."\n";
$code .= '<span class="clTxtW">ZAVE</span>'."\n";
$code .= '</div>'."\n";
$code .= '</a>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="desFileDlZaveLd">'."\n";
$code .= '<span class="fileName cutTxt">'.$arraydata['filezave']['filename'].'</span>'."\n";
$code .= '<span class="fileSize cutTxt">'.$this->formatBytes($arraydata['filezave']['size']).'</span>'."\n";
$code .= '</div>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="wrpOutDlZave">'."\n";
$code .= '<div class="wrpDlZave">'."\n";
$code .= '<a href="'.$arraydata['filezavec']['newpath'].'">'."\n";
$code .= '<div class="btnIco dlZaveLd">'."\n";
$code .= '<span class="ico2 icoDZavelLd"></span>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="btnDlZaveFile">'."\n";
$code .= '<span class="clTxtW">ZAVEC</span>'."\n";
$code .= '</div>'."\n";
$code .= '</a>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="desFileDlZaveLd">'."\n";
$code .= '<span class="fileName cutTxt">'.$arraydata['filezavec']['filename'].'</span>'."\n";
$code .= '<span class="fileSize cutTxt">'.$this->formatBytes($arraydata['filezavec']['size']).'</span>'."\n";
$code .= '</div>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="wrpOutDlZave">'."\n";
$code .= '<div class="wrpDlZave">'."\n";
$code .= '<a href="'.$arraydata['filezavem']['newpath'].'">'."\n";
$code .= '<div class="btnIco dlZaveLd">'."\n";
$code .= '<span class="ico2 icoDZavelLd"></span>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="btnDlZaveFile">'."\n";
$code .= '<span class="clTxtW">ZAVEM</span>'."\n";
$code .= '</div>'."\n";
$code .= '</a>'."\n";
$code .= '</div>'."\n";
$code .= '<div class="desFileDlZaveLd">'."\n";
$code .= '<span class="fileName cutTxt">'.$arraydata['filezavem']['filename'].'</span>'."\n";
$code .= '<span class="fileSize cutTxt">'.$this->formatBytes($arraydata['filezavem']['size']).'</span>'."\n";
$code .= '</div>'."\n";
$code .= '</div>'."\n";
$code .= '</div>'."\n";
$code .= '</div>'."\n";
$code .= '</div>';




}
$code="";
$data['str']=$code;
$data['target']='secondtarget';

return $data;
  
  
  }
  function formatBytes($bytes, $precision = 2) { 
    $units = array('B', 'KB', 'MB', 'GB', 'TB'); 

    $bytes = max($bytes, 0); 
    $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); 
    $pow = min($pow, count($units) - 1); 

    // Uncomment one of the following alternatives
    // $bytes /= pow(1024, $pow);
    // $bytes /= (1 << (10 * $pow)); 

    return round($bytes, $precision) . ' ' . $units[$pow]; 
} 
  
  function getplugin($plugreid)
  {
  
  $sql="select * from tb_plugins_upload_book where plugreid=".$plugreid;
  $arrayplugin=$this->db->db_set_1recordrow($sql);
  $arrayplugin['type']='zave';
  $arrayplugin['filezave']=array();
  
  if($arrayplugin['zave'])
  {
  $sql="select (CONCAT('". baseinfo . "','/', path)) as newpath,filename,name,tb_file.size from tb_file where fileid=".$arrayplugin['zave'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  $arrayplugin['filezave']=$arrayfile;
  }
  
   $arrayplugin['filezavec']=array(); 
  if($arrayplugin['zavec'])
  {
  $sql="select (CONCAT('". baseinfo . "','/', path)) as newpath,filename,name,tb_file.size from tb_file where fileid=".$arrayplugin['zavec'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  $arrayplugin['filezavec']=$arrayfile;
  }
  
  
   $arrayplugin['filezavem']=array(); 
  if($arrayplugin['zavem'])
  {
  $sql="select (CONCAT('". baseinfo . "','/', path)) as newpath,filename,name,tb_file.size from tb_file where fileid=".$arrayplugin['zavem'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  $arrayplugin['filezavem']=$arrayfile;
  }
  
  
  
  

  
  
  return $arrayplugin;
  

  
  
  

  
  }
  
  function saveplugin($arraydata,$productid,$plugreid)
  {
  $arraydata['productid']=$productid;
  $arraydata['plugreid']=$plugreid;
  $arraydata['detail']=$arraydata['detail'];
  if($arraydata['zave'])
  {
  $sql="select path,productid,name from tb_file where fileid=".$arraydata['zave'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  if($arrayfile['productid']==0)
  { 
     $newpath=filepath.'/'.$productid.'/'.$arrayfile['name']   ;
     if(copy($arrayfile['path'],$newpath))
     {
     @chmod($newpath,0777);
     unlink($arrayfile['path']);
     $arrayfile['cache']=0;
     $arrayfile['path']=str_replace(rootpath.'/','',$newpath);
     $arrayfile['productid']=$productid;
     $this->db->db_set($arrayfile,'tb_file',' fileid='.$arraydata['zave']);
     
     
     }
     
     
  
  }
  }
  
  
  if($arraydata['zavec'])
  {
  $sql="select path,productid,name from tb_file where fileid=".$arraydata['zavec'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  if($arrayfile['productid']==0)
  { 
     $newpath=filepath.'/'.$productid.'/'.$arrayfile['name']   ;
     if(copy($arrayfile['path'],$newpath))
     {
     @chmod($newpath,0777);
     unlink($arrayfile['path']);
     $arrayfile['cache']=0;
     $arrayfile['path']=str_replace(rootpath.'/','',$newpath);
     $arrayfile['productid']=$productid;
     $this->db->db_set($arrayfile,'tb_file',' fileid='.$arraydata['zavec']);
     
     
     }
     
     
  
  }
  }
  
  
  if($arraydata['zavem'])
  {
  
  $sql="select path,productid,name from tb_file where fileid=".$arraydata['zavem'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  if($arrayfile['productid']==0)
  { 
     $newpath=filepath.'/'.$productid.'/'.$arrayfile['name']   ;
     if(copy($arrayfile['path'],$newpath))
     {
     @chmod($newpath,0777);
     unlink($arrayfile['path']);
     $arrayfile['cache']=0;
     $arrayfile['path']=str_replace(rootpath.'/','',$newpath);
     $arrayfile['productid']=$productid;
     $this->db->db_set($arrayfile,'tb_file',' fileid='.$arraydata['zavem']);
     
     
     }
     
     
  
  }
  
  }
  
  $this->db->db_set($arraydata,'tb_plugins_upload_book');
  
  }
  
  
  }
?>
